<?php
/**
 * Author: Silent Night
 * email: silentwolf_wp@163.com
 * Date: 2017/10/10
 * Time: 11:02
 */

namespace app\admin\model;

use think\Model;
use think;

class Feedback extends Model{

    
    public function getID($pid)
    {
        $data = array();
        $res = $this->where(['id'=>$pid])
        ->find();
        if($res)
        {
            $data =$res->toArray();
        }
        return $data;
    }
     
    public function lists($w,$pagesize="10")
    {
        $rdata=array();
        if(!empty($w))
            $this->where($w);
        $this->order("id","desc");
        $list = $this->paginate($pagesize)->toArray();
         // echo $this->getLastSql();
        return $list;
    }
    public function getDataForWhere($w)
    {
        $data = array();
        $this->where($w);
        $this->order("id","desc");
        $res =$this ->find();
        if($res)
        {
            $data =$res->toArray();
        }
        return $data;
    }
    public function getDataForWheres($w)
    {
       
        $data = array();
        $this->where($w);
        $this->order("id","desc");
        $res =$this ->select();
//         echo $this->getLastSql();
        if($res)
        {
            $data =$res->toArray();
        }
        return $data;
    }
    

    public function getDataForWheresASC($w)
    {
         
        $data = array();
        $this->where($w);
        $this->order("id","ASC");
        $res =$this ->select();
        //         echo $this->getLastSql();
        if($res)
        {
            $data =$res->toArray();
        }
        return $data;
    }

    public function updateData($update,$id)
    {
       $res=  $this->save($update,['id'=>$id]);
        return $res;
    }
    

    public function updateDataForWhere($update,$where)
    {
        $res=  $this->save($update,$where);
        return $res;
    }
   

    public function add($array){
               $this->save($array);
        return $this->getLastInsID();
    }
    

    public function delData($w){
    
        return $this->where($w)->delete();
    }

}